package dgirard.radar;

import java.util.Comparator;

public class RadarPositionComparator implements Comparator<RadarPosition> {

	
	private static RadarPositionComparator radarPositionComparator = new RadarPositionComparator();
	public int compare(RadarPosition first, RadarPosition second) {
		double distanceFirst = first.getDistance();
		double distanceSecond = second.getDistance();
		
		int result = 0;
		
		if(distanceFirst < distanceSecond){
			result = -1;
		} else if (distanceFirst > distanceSecond){
			result = 1;
		}
		
		return result;
	}
	
	public static RadarPositionComparator getComparator(){
		return radarPositionComparator;
	}

}
